function OOBTUtils() {
};

OOBTUtils.move = function(obj_src, obj_tgt, objects, dir) {
  if (!obj_src) {
    return false;
  }
  
  var pos_src, pos_tgt;
  for (var idx in objects) {
    var obj = objects[idx];
    if (obj.id == obj_src.id) {
      pos_src = idx;
    }
    if (obj.id == obj_tgt.id) {
      pos_tgt = idx;
    }
  }
  
  if (pos_src == pos_tgt) {
    return false;
  }
  
  if (dir) {
    if (pos_tgt == 0) {
      obj_src.order = obj_tgt.order - 1;
      return true;
    } else {
      obj_src.order = obj_tgt.order - ((obj_tgt.order - objects[pos_tgt - 1].order) / 2);
      return true;
    }
  } else {
    if (pos_tgt == objects.length - 1) {
      obj_src.order = parseFloat(obj_tgt.order, 10) + 1;
      return true;
    } else {
      obj_src.order = parseFloat(obj_tgt.order, 10) + ((objects[parseFloat(pos_tgt, 10) + 1].order - obj_tgt.order) / 2);
      return true;
    }
  }
  
  return false;
};
